Page({
  data: {
    bgd141: "",
    bgd142: "",
    bgd143: "",
    bgd144: "",
    bgd145: "",
    bgd146: "",
    bgd147: "",
    bgd148: "",
    bgd149: "",
    bgd150: "",
    bgd151: "",
    bgd152: "",
    bgd153: "",
    bgd154: "",
    bgd155: "",
    bgd156: "",
    bgd157: "",
    bgd158: "",
    bgd159: "",
    bgd160: "",
    bgd161: "",
    bgd162: "",
    bgd163: "",
    bgd164: "",
    bgd165: "",
    bgd166: "",
    bgd167: "",
    bgd168: "",
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;
    wx.request({
      url: 'https://www.szz5.com/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '141') {
              console.info("进来001");
              that.setData({
                bgd141: "red"
              });
            }
            if (bathid == "142") {
              console.info("进来002");
              that.setData({
                bgd142: "red"
              });
            }
            if (bathid == "143") {
              that.setData({
                bgd143: "red"
              });
            }
            if (bathid == "144") {
              that.setData({
                bgd144: "red"
              });
            }
            if (bathid == "145") {
              that.setData({
                bgd145: "red"
              });
            }
            if (bathid == "146") {
              that.setData({
                bgd146: "red"
              });
            }
            if (bathid == "147") {
              that.setData({
                bgd147: "red"
              });
            }
            if (bathid == "148") {
              that.setData({
                bgd148: "red"
              });
            }
            if (bathid == "149") {
              that.setData({
                bgd149: "red"
              });
            }
            if (bathid == "150") {
              that.setData({
                bgd150: "red"
              });
            }
            if (bathid == "151") {
              that.setData({
                bgd151: "red"
              });
            }
            if (bathid == "152") {
              that.setData({
                bgd152: "red"
              });
            }
            if (bathid == "153") {
              that.setData({
                bgd153: "red"
              });
            }
            if (bathid == "154") {
              that.setData({
                bgd154: "red"
              });
            }
            if (bathid == "155") {
              that.setData({
                bgd155: "red"
              });
            }
            if (bathid == "156") {
              that.setData({
                bgd156: "red"
              });
            }
            if (bathid == "157") {
              that.setData({
                bgd157: "red"
              });
            }
            if (bathid == "158") {
              that.setData({
                bg158: "red"
              });
            }
            if (bathid == "159") {
              that.setData({
                bgd159: "red"
              });
            }
            if (bathid == "160") {
              that.setData({
                bgd160: "red"
              });
            }
            if (bathid == "161") {
              that.setData({
                bgd161: "red"
              });
            }
            if (bathid == "162") {
              that.setData({
                bgd162: "red"
              });
            }
            if (bathid == "163") {
              that.setData({
                bgd163: "red"
              });
            }
            if (bathid == "164") {
              that.setData({
                bgd164: "red"
              });
            }
            if (bathid == "165") {
              that.setData({
                bgd165: "red"
              });
            }
            if (bathid == "166") {
              that.setData({
                bgd166: "red"
              });
            }
            if (bathid == "167") {
              that.setData({
                bgd167: "red"
              });
            }
            if (bathid == "168") {
              that.setData({
                bgd168: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'https://www.szz5.com/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})